from django.db import models

from fbase.models import Object
from utils.timezone import astimezone2cst


class RecordBase(Object):
    date = models.DateTimeField(verbose_name='日期')
    desc = models.TextField(max_length=512, verbose_name='描述')
    businessline = models.ForeignKey('organization.BusinessLine', on_delete=models.PROTECT, verbose_name='业务线')
    company = models.ForeignKey('organization.Company', on_delete=models.PROTECT, verbose_name='公司')
    businessdept = models.ForeignKey('organization.BusinessDept', on_delete=models.PROTECT, verbose_name='事业部')

    class Meta:
        abstract = True

    def __str__(self):
        return '{}:{}:{}:{}'.format(
            self.company.name,
            self.businessdept.name,
            self.businessline.name,
            astimezone2cst(self.date)
        )
